seq_file.rs: Borrow data from C pointer#394
seq_file.rs: Borrow data from C pointer#394adamrk wants to merge 3 commits intoRust-for-Linux:rustfrom
Conversation
Adds a trait which allows Rust modules to implement the seq_operations interface and use it to create a `/proc` file. Signed-off-by: Adam Bratschi-Kaye <ark.email@gmail.com>
Signed-off-by: Adam Bratschi-Kaye <ark.email@gmail.com>
Instead of taking ownership of the data from the C side, borrow it using the new `PointerWrapper` interface. Signed-off-by: Adam Bratschi-Kaye <ark.email@gmail.com>
|
Hi Adam, what is the goal here? Is this so Rust kernel components (drivers, fses, etc) can create |
Yes that's the goal. I don't need it for anything specific, more just trying out how wrapping some kernel APIs would work and figured someone might want it at some point. I was planning to add support for |
|
redoing this |
Borrow the
seq_filedata from the C pointer usingPointerWrapper::borrowinstead of taking ownership and then usingmem::forget. This contains the changes of #232.Note: I've added
UnsafeReferenceto thekernelmodule's public interface because the doctest example forseq_filewraps the data in aBox. This means the user is going to need to extract the data from<Box as PointerWrapper>::Borrowwhich isUnsafeReference. Was it intentional that forUnsafeReferenceto not be public?